window.onload = function(){
	var oboy = document.getElementById("boy");
	var ogirl = document.getElementById("girl");
	var otest = document.getElementById("test");
	var ores = document.getElementById("res");
	
	otest.onclick = function(){
		var boy = 0;	/* 存储男的Unicode码的和 */
		var girl = 0;	/* 存储女的Unicode码的和 */ 
		for(var i = 0; i < oboy.value.length; i++){
			boy = boy + oboy.value.charCodeAt(i);
		}
		for(var j = 0; j < ogirl.value.length; j++){
			girl = girl + ogirl.value.charCodeAt(j);
		}
		var res = (boy + girl) % 100;
		
		if(res >= 0 && res <20){
			ores.innerHTML = oboy.value + "和" + ogirl.value + "的缘分值为:" + res + "。" + "你们有缘无分,别浪费时间在上面了。";
		}else if(res >= 20 && res <40){
			ores.innerHTML = oboy.value + "和" + ogirl.value + "的缘分值为:" + res + "。" + "你们有缘无分,但是有可能会成为朋友。";
		}else if(res >= 40 && res <60){
			ores.innerHTML = oboy.value + "和" + ogirl.value + "的缘分值为:" + res + "。" + "你们很有缘,会成为好朋友,但是感情方面还是差点,加油。";
		}else if(res >= 60 && res <80){
			ores.innerHTML = oboy.value + "和" + ogirl.value + "的缘分值为:" + res + "。" + "你们很有缘,努力努力会有很好的结果,加油，奥利给。";
		}else if(res >= 80 && res <100){
			ores.innerHTML = oboy.value + "和" + ogirl.value + "的缘分值为:" + res + "。" + "你们超级有缘,真是天造地设的一对,建议原地结婚。";
		}else{
			ores.innerHTML = "系统出错了！程序员小哥哥正在抢修！"
		}
	}
}